import HeroLogic from "./HeroLogic";

export default class CallLogic {
    constructor()
    {

    }
    private static _instance:CallLogic;
    /**
     * name
     */
    
    public static get instance() : CallLogic {
        if (!this._instance)
        {
            this._instance = new CallLogic()
        }
        return this._instance
    }
    
    /**
     * 召唤英雄
     */
    public callHero(type:number):object {
        let quality:number = 1
        if (type==0)
        {
            quality = 5+Math.floor(Math.random()*2)
        }
        if (type==1)
        {
            quality = 4+Math.floor(Math.random()*2)
        }
        if (type==2)
        {
            quality = 2+Math.floor(Math.random()*2)
        }
        if (type==3)
        {
            quality = Math.floor(Math.random()*1)
        }
        let id:number = Math.floor(20*Math.random());
        let heroObj:object = HeroLogic.instance.createHeroObj(id,1,quality)
        HeroLogic.instance.addHero(heroObj)
        return heroObj;
    }
}
